package com.moon.mybatisplus.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: mybatisPlus 配置拦截器
 * @author: thy
 * @create: 2023-12-15 14:49
 **/
@Configuration
public class MybatisPlusConfig {
    /**
     * 新版
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return mybatisPlusInterceptor;
    }

    /**
     *  tip : mybatisPlus内置分页插件失效??
     *
     *  使用pageHelper
     *  PageHelper.startPage(2, 4);
     *  List<xx> xxs = mapper.selectList(condition);
     *  PageInfo<xx> pageDogs = new PageInfo<>(xxs);
     *
     */
}
